package Recursive_search_backtracking_algorithm.Topic1_recursive_algorithm.Topic1_recursive_algorithm;

public class reverse_linked_list {
    //206. 反转链表
    //https://leetcode.cn/problems/reverse-linked-list/

    public Topic1_recursive_algorithm.ListNode reverseList(Topic1_recursive_algorithm.ListNode head) {
        if(head==null || head.next == null){
            return head;
        }
        Topic1_recursive_algorithm.ListNode newHead = reverseList(head.next);
        head.next.next = head;
        head.next = null;
        return newHead;
    }
}
